import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import User from '../views/User.vue'
import Main from '../views/Main.vue'
import Mall from '../views/Mall.vue'
import PageOne from '../views/PageOne.vue'
import PageTow from '../views/PageTow.vue'



Vue.use(VueRouter)    //  明确全局安装路由，必须在main.js中引入

// 创建路由组件，放在views文件夹下面
const routes = [

    {   //  主路由嵌套子路由写法
        path:'/',
        component:Main,
        redirect:'home',  // 路由重定向
        children:[
            {path:'/home',component:Home},
            {path:'/user',component:User},
            {path:'/main',component:Main},
            {path:'/mall',component:Mall},
            {path:'/page1',component:PageOne},
            {path:'/page2',component:PageTow},
        ]
    }

]

const router = new VueRouter({
    routes  // 相当于routes:routes
})

export default router